<?php
namespace app\admin\controller;


use app\extra\DBCont;
use think\Db;

/**
 * @title 参赛成员
 * @description 接口说明
 * @group 报名管理后台接口
 * @header name:authorization require:1 default: desc:登陆的token
 */
class Member extends Base
{
    protected $_order = 'id desc';
    /**
     * @title 获取
     * @description 接口说明
     * @author hardy
     * @url /admin/Member
     * @method GET
     *
     * @param name:id type:int require:0 default:1 other: desc:唯一ID，获取某条记录详情，则为必填，id和page选填其一
     * @param name:team_id type:int require:0 default:1 other: desc:团队id
     * @param name:name type:int require:0 default:1 other: desc:成员名称
     * @param name:page type:int require:0 default:1 other: desc:页码数 获取第二页以上的数据必填，默认值为1，id和page选填其一
     * @param name:size type:int require:0 default:20 other: desc:每一页的数量，默认20
     * @param name:share_id type:int require:0 default: other: desc:分销员的id
     *
     * @return team_name:团队名称
     * @return name:姓名
     * @return image:照片
     * @return sex:性别：男、女
     * @return age:年龄
     * @return tel:手机号
     * @return card:身份证号
     * @return unit:工作单位
     * @return province:省
     * @return city:市
     * @return area:区
     * @return address:详细地址
     * @return status:审核状态：0待审核，1通过审核，2拒绝
     * @return examine1:问题1：是、否
     * @return examine2:问题2：是、否
     * @return examine3:问题3：是、否
     * @return examine4:问题4：离开原因、否
     * @return accident_insurance:是否接受大赛期间意外伤害保险：是、否
     * @return status_desc:无需交费、线上支付、线下支付、未支付
     *
     * @return list:消息列表,有page参数则返回值list，list是一个数组，
     * @return size:每页最大数，默认20，可由前端传递参数决定 page参数返回值，
     * @return page:当前页，page参数返回值，
     * @return count:总记录数， page参数返回值，
     */
    public function gets()
    {
        parent::gets();

    }
    protected function _searchPage(&$where)
    {
        $data = input('get.');
        $key = 'name';
        if(!empty($data[$key])){
            $where[] = [$key,'like', "%{$data[$key]}%"];
        }
        $key = 'team_id';
        if(!empty($data[$key])){
            $where[] = [$key,'=', $data[$key]];
        }
        $key = 'share_id';
        if(!empty($data[$key])){
            $team_id = model('Team')->where($key,'=', $data[$key])->column('id');
            if (empty($team_id)){
                $where[] = ['team_id','=', -1];
            } else {
                $where[] = ['team_id','IN', $team_id];
            }
        }

    }
    /**
     * @title 创建个人赛
     * @description 创建
     * @author hardy
     * @url /admin/Member
     * @method POST
     *
     *
     * @param name:team_id type:int require:1 default: other: desc:团队id
     * @param name:name type:string require:1 default: other: desc:姓名
     * @param name:image type:int require:1 default: other: desc:照片
     * @param name:sex type:string require:1 default: other: desc:性别：男、女
     * @param name:age type:int require:1 default: other: desc:年龄
     * @param name:tel type:string require:1 default: other: desc:手机号
     * @param name:card type:string require:1 default: other: desc:身份证号码
     * @param name:unit type:string require:1 default: other: desc:工作单位
     * @param name:province type:string require:1 default: other: desc:省
     * @param name:city type:string require:1 default: other: desc:市
     * @param name:area type:string require:1 default: other: desc:区
     * @param name:address type:string require:1 default: other: desc:详细地址
     * @param name:status type:int require:0 default: other: desc:审核状态：0待审核，1通过审核，2拒绝
     * @param name:examine1 type:string require:1 default: other: desc:问题1：是、否
     * @param name:examine2 type:string require:1 default: other: desc:问题2：是、否
     * @param name:examine3 type:string require:1 default: other: desc:问题3：是、否
     * @param name:examine4 type:string require:1 default: other: desc:问题4：离开原因、否
     * @param name:accident_insurance type:string require:1 default: other: desc:是否接受大赛期间意外伤害保险：是、否
     *
     *
     * @return team_name:团队名称
     * @return name:姓名
     * @return image:照片
     * @return sex:性别：男、女
     * @return age:年龄
     * @return tel:手机号
     * @return card:身份证号
     * @return unit:工作单位
     * @return province:省
     * @return city:市
     * @return area:区
     * @return address:详细地址
     * @return status:审核状态：0待审核，1通过审核，2拒绝
     * @return examine1:问题1：是、否
     * @return examine2:问题2：是、否
     * @return examine3:问题3：是、否
     * @return examine4:问题4：离开原因、否
     * @return accident_insurance:是否接受大赛期间意外伤害保险：是、否
     */
    public function create(){
        $data = input('post.');
        unset($data['id']);
        $data['way'] = DBCont::OFFLINE;
        $data['pay_state'] = DBCont::SUCCESS;
        $r = model('Member')->addMember($data, $data['team_id']);
        if ($r === false){
            $this->responseFail(model('Member')->getError());
        }
        $this->responseSuccess($r, '提交成功');
    }
    /**
     * @title 修改
     * @description 接口说明：修改接口除了id必填，其余的都为选填，上传需要修改的字段或状态
     * @author hardy
     * @url /admin/Member
     * @method put
     *
     *
     * @param name:id type:int require:1 default: other: desc:id
     * @param name:team_id type:int require:0 default: other: desc:团队id
     * @param name:name type:string require:0 default: other: desc:姓名
     * @param name:image type:int require:0 default: other: desc:照片
     * @param name:sex type:string require:0 default: other: desc:性别：男、女
     * @param name:age type:int require:0 default: other: desc:年龄
     * @param name:tel type:string require:0 default: other: desc:手机号
     * @param name:card type:string require:0 default: other: desc:身份证号码
     * @param name:unit type:string require:0 default: other: desc:工作单位
     * @param name:province type:string require:0 default: other: desc:省
     * @param name:city type:string require:0 default: other: desc:市
     * @param name:area type:string require:0 default: other: desc:区
     * @param name:address type:string require:0 default: other: desc:详细地址
     * @param name:status type:int require:0 default: other: desc:审核状态：0待审核，1通过审核，2拒绝
     * @param name:examine1 type:string require:0 default: other: desc:问题1：是、否
     * @param name:examine2 type:string require:0 default: other: desc:问题2：是、否
     * @param name:examine3 type:string require:0 default: other: desc:问题3：是、否
     * @param name:examine4 type:string require:0 default: other: desc:问题4：离开原因、否
     *
     * @return team_name:团队名称
     * @return name:姓名
     * @return image:照片
     * @return sex:性别：男、女
     * @return age:年龄
     * @return tel:手机号
     * @return card:身份证号
     * @return unit:工作单位
     * @return province:省
     * @return city:市
     * @return area:区
     * @return address:详细地址
     * @return status:审核状态：0待审核，1通过审核，2拒绝
     * @return examine1:问题1：是、否
     * @return examine2:问题2：是、否
     * @return examine3:问题3：是、否
     * @return examine4:问题4：离开原因、否
     * @return accident_insurance:是否接受大赛期间意外伤害保险：是、否
     */
    public function update(){
        parent::update();
    }
    /**
     * @title 删除
     * @description 接口说明
     * @author hardy
     * @url /admin/Member
     * @method delete
     *
     *
     * @param name:id type:int|string|array require:1 default: other: desc:单个删除：数字，多组删除：","隔开的数字或者数组
     *
     */
    public function delete(){
        parent::delete();
    }
}